-
Notifications
You must be signed in to change notification settings - Fork 967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Battery level with proportional filter and lookup table #3216
Battery level with proportional filter and lookup table #3216
Conversation
now uses a lookup table to better calculate battery level of different cells
removed delay from adc reading, added a software filter to smooth out voltage readings. In those applications battery would last hours to days, no sudden change should be expected so a less frequent voltage reading or a more aggressive filtering could be done. Note: to speed up convergence i initiliazied the last value to the minimum voltage, there are other and better ways to init the filter. Added LiFePO4 and PB open circuit volta battery tables,
line 230/386 For heltec v3 and heltec tracker a different approach was used with the ADC_CTRL pin, now is more uniform using the same code for the 3 boards. line 236 Check if the raw reading we are getting is Valid or not, count only the valid readings. This could lead to a division by 0 (improbable) so that's why at line 258 there is a check for that.
updated value to not OCV but to very low current, almost the same anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Voltage ranges look good. Could you modify any other variant.h files that might be using the existing BAT_FULLVOLT or other similar macros? I think variants/station-g1 might be using it
Run trunk fmt
as well, to make the CI checks happy.
Added Alkaline/Nimh voltage curve for AA/AAA and similar cells
Ok, added also Nimh/Alkaline cells that were used by another variant
Done but some checks still don't pass, if i run trunk fmt won't it reformat every file? |
Nicely done, I'll take a look at the trunk stuff tonight to see if I can't roundhouse kick it into working. |
@thebentern OK should be ready for your discerning eye. |
Add a more precise battery level estimation based on a Open Circuit Voltage table.
A P controller acts as a low pass filter to smooth out the voltage readings and on that is applied a OCV table to estimate more precisely different kind of cells chemistry.
Now supported:
With a variable number of cells.
A valid voltage reading counter was added to avoid doing an ADC average on incorrect values.
Heltec V2.1 voltage multiplier was corrected.